package com.yueya.basic.notice.model;

import com.jfinal.plugin.activerecord.Model;
import com.yueya.common.util.DateUtil;
import com.yueya.common.util.UUIDGenerator;

@SuppressWarnings("serial")
public class NoticeStatus extends Model<NoticeStatus> {

	public static final NoticeStatus dao = new NoticeStatus();

	/**
	 * 保存阅读状态
	 * 
	 * @param noticeId
	 * @param userId
	 * @return
	 */
	public boolean saveReadStatus(String noticeId, String userId) {
		NoticeStatus ts = NoticeStatus.dao
				.findFirst("select * from  t_notice_status where notice_id = ? and user_id = ?", noticeId, userId);
		boolean bl = true;
		if (ts == null) {
			ts = new NoticeStatus();
			ts.set("id", UUIDGenerator.getUUID());
			ts.set("user_id", userId);
			ts.set("notice_id", noticeId);
			ts.set("create_time", DateUtil.getDate(DateUtil.timeFormat));
			bl = ts.save();
		}

		return bl;
	}

}
